package com.yao.club.reposittory;

import com.yao.club.entity.dto.GoodsFootPrintRecord;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface GoodsFootPrintRecordRepository extends JpaRepository<GoodsFootPrintRecord, Long> {
    
    /**
     * 查找用户当天的商品浏览记录
     */
    @Query("SELECT f FROM GoodsFootPrintRecord f WHERE f.goodsId = :goodsId " +
           "AND f.userId = :userId ")
    GoodsFootPrintRecord findByGoodsIdAndUserIdAndDate(
        @Param("goodsId") Long goodsId,
        @Param("userId") Long userId);

    /**
     * 根据用户ID查询浏览足迹
     */
    List<GoodsFootPrintRecord> findByUserId(Long userId);
}
